package io.github.cocoa.module.socket.api.sample;

import io.github.cocoa.framework.common.pojo.CommonResult;
import io.github.cocoa.module.socket.api.sample.dto.SampleInfoRespDTO;
import io.github.cocoa.module.socket.convert.sample.SampleInfoConvert;
import io.github.cocoa.module.socket.dal.dataobject.sample.SampleInfoDO;
import io.github.cocoa.module.socket.service.sample.SampleInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static io.github.cocoa.framework.common.pojo.CommonResult.success;

/**
 * Created by IntelliJ IDEA.
 *
 * @author James
 */
@RestController // 提供 RESTFul API 接口, 给 Feign 调用
@Validated
public class SampleInfoApiImpl implements SampleInfoApi {
    @Resource
    private SampleInfoService sampleInfoService;

    @Override
    public CommonResult<SampleInfoRespDTO> getUser(Long id) {
        SampleInfoDO sampleInfo = sampleInfoService.getInfo(id);
        return success(SampleInfoConvert.INSTANCE.convertDTO(sampleInfo));
    }
}
